home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / HTML Spy277011062001.psc / HtmlSpy / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-09-21  |  7.1 KB  |  217 lines

  1. VERSION 5.00
  2. Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "shdocvw.dll"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
  5. Begin VB.Form Form1 
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "HTML Spy"
  8.    ClientHeight    =   7335
  9.    ClientLeft      =   150
  10.    ClientTop       =   720
  11.    ClientWidth     =   11985
  12.    Icon            =   "frmMain.frx":0000
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   7335
  17.    ScaleWidth      =   11985
  18.    StartUpPosition =   3  'Windows Default
  19.    Begin MSComctlLib.ImageList ImageList1 
  20.       Left            =   6630
  21.       Top             =   7200
  22.       _ExtentX        =   1005
  23.       _ExtentY        =   1005
  24.       BackColor       =   -2147483643
  25.       ImageWidth      =   16
  26.       ImageHeight     =   16
  27.       MaskColor       =   12632256
  28.       _Version        =   393216
  29.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  30.          NumListImages   =   2
  31.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  32.             Picture         =   "frmMain.frx":000C
  33.             Key             =   ""
  34.          EndProperty
  35.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  36.             Picture         =   "frmMain.frx":045E
  37.             Key             =   ""
  38.          EndProperty
  39.       EndProperty
  40.    End
  41.    Begin RichTextLib.RichTextBox Text2 
  42.       Height          =   1785
  43.       Left            =   6930
  44.       TabIndex        =   6
  45.       Top             =   5430
  46.       Width           =   4965
  47.       _ExtentX        =   8758
  48.       _ExtentY        =   3149
  49.       _Version        =   393217
  50.       TextRTF         =   $"frmMain.frx":08B0
  51.    End
  52.    Begin RichTextLib.RichTextBox Text1 
  53.       Height          =   1845
  54.       Left            =   6930
  55.       TabIndex        =   5
  56.       Top             =   3270
  57.       Width           =   4965
  58.       _ExtentX        =   8758
  59.       _ExtentY        =   3254
  60.       _Version        =   393217
  61.       TextRTF         =   $"frmMain.frx":093B
  62.    End
  63.    Begin VB.Timer Timer1 
  64.       Interval        =   300
  65.       Left            =   2010
  66.       Top             =   7290
  67.    End
  68.    Begin VB.CommandButton Command1 
  69.       Caption         =   "Go"
  70.       Height          =   315
  71.       Left            =   6330
  72.       TabIndex        =   3
  73.       Top             =   270
  74.       Width           =   525
  75.    End
  76.    Begin VB.TextBox txtUrl 
  77.       Height          =   315
  78.       Left            =   480
  79.       TabIndex        =   1
  80.       Top             =   240
  81.       Width           =   5805
  82.    End
  83.    Begin MSComctlLib.TreeView TreeView1 
  84.       Height          =   2745
  85.       Left            =   6930
  86.       TabIndex        =   0
  87.       Top             =   240
  88.       Width           =   4935
  89.       _ExtentX        =   8705
  90.       _ExtentY        =   4842
  91.       _Version        =   393217
  92.       LineStyle       =   1
  93.       Style           =   5
  94.       ImageList       =   "ImageList1"
  95.       Appearance      =   1
  96.    End
  97.    Begin SHDocVwCtl.WebBrowser WebBrowser1 
  98.       Height          =   6585
  99.       Left            =   120
  100.       TabIndex        =   4
  101.       Top             =   630
  102.       Width           =   6705
  103.       ExtentX         =   11827
  104.       ExtentY         =   11615
  105.       ViewMode        =   0
  106.       Offline         =   0
  107.       Silent          =   0
  108.       RegisterAsBrowser=   0
  109.       RegisterAsDropTarget=   1
  110.       AutoArrange     =   0   'False
  111.       NoClientEdge    =   0   'False
  112.       AlignLeft       =   0   'False
  113.       ViewID          =   "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
  114.       Location        =   "res://C:\WINNT\system32\shdoclc.dll/dnserror.htm#http:///"
  115.    End
  116.    Begin VB.Label Label3 
  117.       Caption         =   "InnerHTML"
  118.       Height          =   225
  119.       Left            =   6930
  120.       TabIndex        =   8
  121.       Top             =   5190
  122.       Width           =   1395
  123.    End
  124.    Begin VB.Label Label2 
  125.       Caption         =   "InnerText"
  126.       Height          =   225
  127.       Left            =   6960
  128.       TabIndex        =   7
  129.       Top             =   3030
  130.       Width           =   1395
  131.    End
  132.    Begin VB.Label Label1 
  133.       Caption         =   "Url"
  134.       Height          =   285
  135.       Left            =   180
  136.       TabIndex        =   2
  137.       Top             =   270
  138.       Width           =   255
  139.    End
  140.    Begin VB.Menu mnuFile 
  141.       Caption         =   "&File"
  142.       Begin VB.Menu mnuQuit 
  143.          Caption         =   "&Quit"
  144.       End
  145.    End
  146.    Begin VB.Menu mnuHelp 
  147.       Caption         =   "&Help"
  148.       Begin VB.Menu mnuAbout 
  149.          Caption         =   "&About"
  150.       End
  151.    End
  152. Attribute VB_Name = "Form1"
  153. Attribute VB_GlobalNameSpace = False
  154. Attribute VB_Creatable = False
  155. Attribute VB_PredeclaredId = True
  156. Attribute VB_Exposed = False
  157. Option Explicit
  158. Private WithEvents doc As HTMLDocument
  159. Attribute doc.VB_VarHelpID = -1
  160. Dim currentelement As Object
  161. Dim processing  As Boolean
  162. Dim col As Collection
  163. Private Sub Command1_Click()
  164.         Me.WebBrowser1.Navigate Me.txtUrl
  165. End Sub
  166. Private Sub doc_onmouseover()
  167.         If processing Then Exit Sub
  168.         Dim nod As Node
  169.         Me.TreeView1.Nodes.Clear
  170.         Set nod = Me.TreeView1.Nodes.Add(, , , "<" & doc.parentWindow.event.srcElement.tagName & ">", 1)
  171.         Set currentelement = doc.parentWindow.event.srcElement
  172.         col.Add currentelement
  173.         currentelement.Style.border = "solid"
  174.         ProcessAttributes currentelement, nod
  175. End Sub
  176. Private Sub Form_Load()
  177.         Me.WebBrowser1.Navigate "about:<br><br><br><br><br><br><i>Enter the URL in the Addressbar to load the HTML document</i>"
  178.         Set col = New Collection
  179. End Sub
  180. Private Sub mnuAbout_Click()
  181.         aboutme.Show vbModal
  182. End Sub
  183. Private Sub mnuQuit_Click()
  184.         Unload Me
  185. End Sub
  186. Private Sub Timer1_Timer()
  187.         If col.Count >= 2 Then
  188.            col.Item(1).Style.border = ""
  189.            col.Remove 1
  190.         End If
  191. End Sub
  192. Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
  193.         Set doc = Me.WebBrowser1.Document
  194. End Sub
  195. Public Sub ProcessAttributes(objElement As Object, parentNode As Node)
  196.       ' Dim nod As Node
  197.        processing = True
  198.        Dim lastnode As Node
  199.        Me.Text1 = objElement.innerText
  200.        Me.Text2 = objElement.innerHTML
  201.        Dim objAttribute As Object
  202.        Dim i As Integer
  203.        If objElement.Attributes.length > 0 Then
  204.           For i = 0 To objElement.Attributes.length - 1
  205.           Set objAttribute = objElement.Attributes(i)
  206.            DoEvents
  207.               If Len(Trim(objAttribute.nodeValue)) > 0 Then
  208.                 Set lastnode = Me.TreeView1.Nodes.Add(parentNode, tvwChild, , objAttribute.nodeName & " = " & objAttribute.nodeValue, 2)
  209.                 'Label4 = objAttribute.nodeName
  210.                 lastnode.EnsureVisible
  211.               End If
  212.            DoEvents
  213.           Next
  214.        End If
  215.        processing = False
  216. End Sub
  217.